package com.xxc.hs.funActivity.panel;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

import com.bumptech.glide.Glide;
import com.xxc.hs.R;

public class ImagePreviewActivity extends AppCompatActivity {

    public static final String EXTRA_IMAGE_RES_ID = "imageResId";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_image_preview);

        try {
            // 获取图片资源ID
            int imageResId = getIntent().getIntExtra(EXTRA_IMAGE_RES_ID, 0);
            if (imageResId == 0) {
                finish();
                return;
            }

            // 加载图片
            ImageView ivPreview = findViewById(R.id.iv_preview);
            Glide.with(this)
                    .load(imageResId)
                    .into(ivPreview);

            // 关闭按钮点击事件
            findViewById(R.id.iv_close).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    finish();
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}